<!doctype html>
<html lang="en" class="fixed">

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=no"/>
    <title>选择教师</title>
    <link rel="apple-touch-icon" sizes="120x120" href="favicon/apple-icon-120x120.png">
    <link rel="icon" type="image/png" sizes="192x192" href="favicon/android-icon-192x192.png">
    <link rel="icon" type="image/png" sizes="32x32" href="favicon/favicon-32x32.png">
    <link rel="icon" type="image/png" sizes="16x16" href="favicon/favicon-16x16.png">
    <link rel="stylesheet" type="text/css"
          href="<?php xcho(loadSource('/assets/plugins/bootstrap/css/bootstrap.min.css')) ?>">
    <link rel="stylesheet" href="<?php xcho(loadSource('/assets/plugins/animate.css/animate.css')) ?>">
    <link rel="stylesheet" href="<?php xcho(loadSource('/assets/plugins/font-awesome/css/font-awesome.css')) ?>">
    <link rel="stylesheet"
          href="<?php xcho(loadSource('/assets/plugins/data-table/media/css/dataTables.bootstrap.min.css')) ?>">
    <!--    <link rel="stylesheet" href="-->
    <?php //xcho(loadSource('/assets/plugins/ztree/css/zTreeStyle/zTreeStyle.css')) ?><!--">-->
    <link rel="stylesheet" href="<?php xcho(loadSource('/assets/plugins/layui/css/layui.css')) ?>" media="all">
    <link rel="stylesheet" href="<?php xcho(loadSource('/assets/plugins/fullcalendar/fullcalendar.min.css')) ?>">
    <link rel="stylesheet" href="<?php xcho(loadSource('/assets/plugins/ztree/css/metroStyle/metroStyle.css')) ?>"
          type="text/css">
    <link rel="stylesheet" href="<?php xcho(loadSource('/app/css/style.css')) ?>">
    <link rel="stylesheet" href="<?php xcho(loadSource('/app/css/app.css')) ?>">
    <link rel="stylesheet" href="<?php xcho(loadSource('/assets/css/new_main.css')) ?>">
    
    <style>
        * {
            margin:: 0;
            padding: 0;
            box-sizing: border-box;
        }

        ul, li, ol, li {
            list-style: none;
        }

        body {
            background: #f4f4f4;
        }

        .teacher-content {
            width: 1300px;
            margin: 0 auto;
        }

        /*-----------------------------teacher-left-----------------*/
        .teacher-content .teacher-cont .teacher-left {
            width: 490px;
            display: inline-block;
            float: left;
        }

        .teacher-content .teacher-cont .teacher-left .teacher-title {
            padding: 10px 20px;
            background: #fff;
        }

        .teacher-content .teacher-cont .teacher-left .teacher-title h3 {
            font-size: 12px;
            border-bottom: 1px #eee solid;
            padding-bottom: 10px;
        }

        .teacher-content .teacher-cont .teacher-left .teacher-title .range {
            margin-top: 10px;
        }

        .teacher-content .teacher-cont .teacher-left .teacher-title .range p {
            display: inline-block;
            margin-right: 10px;
            font-size: 12px;
        }

        .teacher-content .teacher-cont .teacher-left .teacher-title .range select {
            width: 60px;
            margin-right: 10px;
            height: 24px;
            border: 1px #ccc solid;
            font-size: 10px;
            color: #333;
            border-radius: 5px;
        }

        .teacher-content .teacher-cont .teacher-left .teacher-title .range select option {
            font-size: 10px;
        }

        .teacher-content .teacher-cont .teacher-left .teacher-title .range input {
            margin-right: 10px;
            width: 150px;
            height: 24px;
            border-radius: 5px;
            border: none;
            border: 1px #ccc solid;
            outline: none;
            font-size: 10px;
            text-indent: 10px;
        }

        .teacher-content .teacher-cont .teacher-left .teacher-title .next button {
            padding: 2px 16px;
            background: rgba(16, 142, 233, .6);
            color: #fff;
            border: none;
            border-radius: 6px;
            font-size: 12px;
        }

        .teacher-content .teacher-cont .teacher-left .teacher-title .next button:hover {
            background: #1ab394;
        }

        /*-----------------------------teacher-left-bottom-----------------*/
        .teacher-content .teacher-cont .teacher-left .teacher-content-cont {
            background: #fff;
            padding: 10px 20px;
            margin-top: 10px;
        }

        .teacher-content .teacher-cont .teacher-left .teacher-content-cont .top_pages {
            height: 30px;
            margin-top: 8px;
            font-size: 0;
        }

        .teacher-content .teacher-cont .teacher-left .teacher-content-cont .top_pages p {
            display: inline-block;
            font-size: 12px;
        }

        .teacher-content .teacher-cont .teacher-left .teacher-content-cont .top_pages ul li:nth-of-type(1) {
            border: none;
            background: none;
        }

        .teacher-content .teacher-cont .teacher-left .teacher-content-cont .top_pages ul li:nth-of-type(1):hover {
            background: none;
            color: #999;
        }

        .teacher-content .teacher-cont .teacher-left .teacher-content-cont .top_pages ul li {
            display: inline-block;
            font-size: 12px;
            width: 24px;
            height: 24px;
            background: #fff;
            margin-left: 8px;
            line-height: 24px;
            text-align: center;
            border-radius: 6px;
            cursor: pointer;
            color: #999;
        }

        .teacher-content .teacher-cont .teacher-left .teacher-content-cont .top_pages ul li:last-child {
            border: none;
            background: none;
        }

        .teacher-content .teacher-cont .teacher-left .teacher-content-cont .top_pages ul li:last-child input {
            width: 50px;
            margin: 0 10px;
            border-radius: 6px;
            border: none;
            border: 1px #ccc solid;
            outline: none;
        }

        .teacher-content .teacher-cont .teacher-left .teacher-content-cont .top_pages ul li:last-child:hover {
            background: none;
            color: #999;
        }

        .teacher-content .teacher-cont .teacher-left .teacher-content-cont .top_pages ul li:hover {
            background: #108EE9;
            color: #fff;
        }

        .teacher-content .teacher-cont .teacher-left .teacher-content-cont .table {
            width: 100%;
            margin-top: 10px;
        }

        .teacher-content .teacher-cont .teacher-left .teacher-content-cont .table table {
            width: 100%;
        }

        .teacher-content .teacher-cont .teacher-left .teacher-content-cont .table table thead tr th {
            padding: 10px;
            background: #1ab394;
            color: #fff;
            text-align: center;
        }

        .teacher-content .teacher-cont .teacher-left .teacher-content-cont .table table thead tr th:nth-of-type(1) span {
            display: inline-block;
            width: 12px;
            height: 12px;
            border: 1px #888 solid;
            background: #fff;
            margin-right: 20px;
            position: relative;
            cursor: pointer;
        }

        .teacher-content .teacher-cont .teacher-left .teacher-content-cont .table table thead tr th:nth-of-type(1) span b {
            position: absolute;
            left: 28%;
            top: -60%;
        }

        .teacher-content .teacher-cont .teacher-left .teacher-content-cont .table table tbody tr {
            border-bottom: 1px #ccc solid;
        }

        .teacher-content .teacher-cont .teacher-left .teacher-content-cont .table table tbody tr:nth-of-type(even) {
            background: rgba(238, 238, 238, .5);
        }

        .teacher-content .teacher-cont .teacher-left .teacher-content-cont .table table tbody tr td {
            padding: 8px;
            border-bottom: 1px #eee solid;
            text-align: center;
        }
        .teacher-content .teacher-cont .teacher-left .teacher-content-cont .table table tbody tr td.selectTea{
            cursor: pointer;
        }
        .teacher-content .teacher-cont .teacher-left .teacher-content-cont .table table tbody tr td:nth-of-type(1) {
            color: #108EE9;
        }

        .teacher-content .teacher-cont .teacher-left .teacher-content-cont .table table tbody tr td:last-child span {
            margin: 0 5px;
            color: #108EE9;
            cursor: pointer;
        }

        .teacher-content .teacher-cont .teacher-left .teacher-content-cont .bottom_pages {
            padding: 3px 15px;
            height: 30px;
            margin-top: 8px;
            background: #fff;
            font-size: 0;
        }

        /*------------------teacher-right----------------*/
        .teacher-content .teacher-cont .teacher-right {
            width: 600px;
            background: #fff;
            display: inline-block;
            padding: 10px 20px;
            margin-left: 15px;
        }

        .teacher-content .teacher-cont .teacher-right .teacher-schedule button {
            padding: 4px 14px;
            border: none;
            border-radius: 5px;
            background: rgba(16, 142, 233, .6);
            color: #fff;
            font-size: 12px;
            margin-left: 10px;
        }

        .teacher-content .teacher-cont .teacher-right .teacher-schedule h4 {
            display: inline-block;
            margin-left: 100px;
            font-size: 12px;
        }

        .teacher-content .teacher-cont .teacher-right .teacher-schedule table {
            width: 100%;
        }

        .teacher-content .teacher-cont .teacher-right .teacher-schedule table thead tr {
            border-bottom: 3px #eee solid;

        }

        .teacher-content .teacher-cont .teacher-right .teacher-schedule table thead tr th {
            text-align: center;
            padding: 10px 0;
        }

        .teacher-content .teacher-cont .teacher-right .teacher-schedule table tbody tr {
            border-bottom: 3px #eee solid;
        }

        .teacher-content .teacher-cont .teacher-right .teacher-schedule table tbody tr span {
            color: #333;
        }

        .teacher-content .teacher-cont .teacher-right .teacher-schedule table tbody tr span b {
            padding: 2px 4px;
            font-weight: normal;
            font-size: 10px;
            color: #fff;
            background: #1ab394;
            border-radius: 5px;
        }

        .teacher-content .teacher-cont .teacher-right .teacher-schedule table tbody tr ul {
            padding: 4px 10px;
        }

        .teacher-content .teacher-cont .teacher-right .teacher-schedule table tbody tr td:nth-of-type(even) ul:nth-of-type(odd) {
            background: rgba(238, 238, 238, .5);
        }

        .teacher-content .teacher-cont .teacher-right .teacher-schedule table tbody tr td:nth-of-type(odd) ul:nth-of-type(even) {
            background: rgba(238, 238, 238, .5);
        }

        .teacher-content .teacher-cont .teacher-right .teacher-schedule table tbody tr td {
            vertical-align: initial;
            padding: 10px 0;
        }

        .teacher-content .teacher-cont .teacher-right .teacher-schedule table tbody tr td ul li {
            line-height: 24px;
            font-size: 12px;
        }

        .teacher-content .teacher-cont .teacher-right .teacher-schedule table tbody tr td ul li:nth-of-type(3) {
            color: #108EE9;
        }
        .pagination{
            margin: 0;
        }
        .fc button, .fc-button-group, .fc-time-grid .fc-event .fc-time span{
            display: inherit;
        }
        .keB .student-title{
            text-align: center;
            margin-bottom: 15px;
        }
        .keB .student-title h2{
            font-size:18px;
        }
    </style>
</head>

<body><?php include_once TPL_PATH . 'public/nav.phtml'; ?>

<div class="teacher-content">
    <div class="teacher-cont">
        <div class="teacher-left">
            <form action="<?php xcho($sSearchAction); ?>" method="get" enctype="application/x-www-form-urlencoded">
                <div class="teacher-title">
                    <h3>选择教师-双击选择教师</h3>
                    <div class="range next">
                        <p>日期：</p>
                        <input type="date"  name="date" id="date"
                               value="<?php xcho($aSearch['date']??'') ?>"
                               placeholder="年/月/日">
                        <p>时间：</p>
                        <select name="times" id="times">
                            <?php foreach ($aAuditionTimes as $aTmps) { ?>
                                <option value="<?php xcho($aTmps['dict_value']) ?>"
                                    <?php if ($aTmps['dict_value'] == ($aSearch['times']??'')) { ?>
                                        selected="selected"
                                    <?php } ?>><?php xcho($aTmps['cn_name']) ?></option>
                            <?php } ?>
                        </select>
                    </div>
                    <div class="range next">
                        <p>课目：</p>
                        <select name="subject">
                            <option value=""<?php if ($aSearch['tsubject'] == '') { ?> selected="selected"<?php } ?>>
                                请选择
                            </option>
                            <?php foreach ($aSubjects as $aSubject) { ?>
                                <option value="<?php xcho($aSubject['dict_value']); ?>"<?php if ($aSearch['tsubject'] == $aSubject['dict_value']) { ?> selected="selected"<?php } ?>><?php xcho($aSubject['cn_name']); ?></option>
                            <?php } ?>
                        </select>
                        <?php if(isset($aWhetherList)){?>
                            <p>是否显示忙碌教师：</p>
                            <select name="whether">
                                <?php foreach ($aWhetherList as $aWhether) { ?>
                                    <option value="<?php xcho($aWhether['dict_value']); ?>"<?php if ($aSearch['whether'] == $aWhether['dict_value']) { ?> selected="selected"<?php } ?>><?php xcho($aWhether['cn_name']); ?></option>
                                <?php } ?>
                            </select>
                        <?php }?>
                    </div>
                    <div class="range next">
                        <p>搜索：</p>
                        <input type="text" name="keyword" class="search_input" value="<?php xcho($aSearch['keyword']); ?>"
                               placeholder="可搜索学员名">
                        <button id="search">确认</button>
                    </div>
                </div>
                <div class="teacher-content-cont">
                    <div class="top_pages bottom_pages">
                        <ul>
                            <?php xchoHtml($aOTeachers->render()) ?>
                        </ul>
                    </div>
                    <div class="layui-form table">
                        <table>
                            <thead>
                            <tr>
                                <th><?php if ($iOrderBy == 1) { ?><a href="<?php xcho($aOrderURLs[2]); ?>">
                                            教师姓名</a><?php } else { ?><a href="<?php xcho($aOrderURLs[1]); ?>">
                                            教师姓名</a><?php } ?></th>
                                <th>最大授课</th>
                                <th>课目</th>
                                <th>操作</th>
                            </tr>
                            </thead>
                            <tbody>
                            <?php foreach ($aOrderTeachers as $aTeacher) { ?>
                                <tr data-id="<?php xcho($aTeacher["id"]) ?>">
                                    <td class="selectTea">
                                        <a ondblclick="addParent('<?php xcho($aTeacher["id"]) ?>','<?php xcho($aTeacher["tname"]) ?>')"
                                           style="color: #108EE9; cursor:pointer">
                                            <?php xcho($aTeacher['tname']); ?></a>
                                    </td>
                                    <td><?php xcho($aTeacher['max_simul']); ?></td>
                                    <td><?php xcho(join(',', $aTeacher['tsubject_str'])); ?></td>
                                    <td><a class="layui-btn layui-btn-mini seeKeb">查看课表</a>
                                        <a class="layui-btn layui-btn-mini" href="<?php xcho($aTeacher['info_url']) ?>">教师详情</a></td>
                                </tr>
                            <?php } ?>
                            </tbody>
                        </table>
                    </div>
                    <div class="top_pages bottom_pages">
                        <ul>
                            <?php xchoHtml($aOTeachers->render()) ?>
                        </ul>
                    </div>
                </div>
            </form>
        </div>
        <div class="teacher-right">
            <div class="keB">
                <div class="student-title">
                    <h2></h2>
                </div>
                <div id='calendar'></div>
            </div>
        </div>
    </div>
</div>
<div class="modal fade" id="check-group" tabindex="-1" role="dialog" aria-labelledby="modal-info-label">
    <div class="modal-dialog" role="document">
        <div class="modal-content">
            <div class="modal-header state modal-info">
                <button type="button" class="close" data-dismiss="modal" aria-label="Close"><span aria-hidden="true">&times;</span>
                </button>
                <h4 class="modal-title" id="modal-info-label"><i class="fa fa-info"></i>排课冲突提醒</h4>
            </div>
            <div class="modal-body layui-form" style="min-height: 150px;">
                <table class="table table-condensed">
                    <thead>
                        <th>课程</th>
                        <th>学生</th>
                        <th>时间</th>
                    </thead>
                    <tbody id="show_data">
                    </tbody>
                </table>
            </div>
            <div class="modal-footer">
                <span type="button" class="btn btn-info" id="save" data-dismiss="modal" data-id="" data-name="">确定</span>
                <span type="button" class="btn btn-default" id="return" data-dismiss="modal">取消</span>
            </div>
        </div>
    </div>
</div>
<!--初试日期-->
<input type="hidden" id="date_time" name="date_time" value="<?php xcho($sDates)?>">
<!--ajax地址-->
<input type="hidden" id="ajax_url" name="ajax_url" value="<?php xcho($sSearchAjax)?>">
<script src="<?php xcho(loadSource('/assets/plugins/jquery/jquery.min.js')) ?>"></script>
<script src="<?php xcho(loadSource('/assets/plugins/fullcalendar/lib/moment.min.js')) ?>"></script>
<script src="<?php xcho(loadSource('/assets/plugins/fullcalendar/fullcalendar.min.js')) ?>"></script>
<script src="<?php xcho(loadSource('/assets/plugins/layui/layui.all.js')) ?>" charset="utf-8"></script>
<script src="<?php xcho(loadSource('/assets/plugins/bootstrap/js/bootstrap.min.js')) ?>"></script>
<script src="<?php xcho(loadSource('/assets/plugins/data-table/media/js/jquery.dataTables.min.js')) ?>"></script>
<script src="<?php xcho(loadSource('/assets/plugins/data-table/media/js/dataTables.bootstrap.min.js')) ?>"></script>
<script src="<?php xcho(loadSource('/assets/plugins/layer-v3.0.3/layer/layer.js')) ?>"></script>
<script
        src="<?php xcho(loadSource('/assets/plugins/data-table/extensions/Responsive/js/dataTables.responsive.min.js')) ?>"></script>
<script
        src="<?php xcho(loadSource('/assets/plugins/data-table/extensions/Responsive/js/responsive.bootstrap.min.js')) ?>"></script>
<script src="<?php xcho(loadSource('/assets/plugins/ztree/js/jquery.ztree.core.js')) ?>"></script>
<script type="text/javascript"
        src="<?php xcho(loadSource('/assets/plugins/ztree/js/jquery.ztree.excheck.js')) ?>"></script>
<script type="text/javascript"
        src="<?php xcho(loadSource('/assets/plugins/ztree/js/jquery.ztree.exedit.js')) ?>"></script>
<script>

    $(function () {
        $("#checkAll").click(function () {
            $("input[name='ck']").each(function () {
                if ($(this).prop("checked")) {
                    $(this).prop("checked", false);
                }
                else {
                    $(this).prop("checked", "true");
                }
            })
        });
        $(".top_more").hover(function () {
            $(this).find("ul").show();
        }, function () {
            $(this).find("ul").hide();
        })
        $("table tr>td>span").hover(function () {
            $(this).find("b").show();
        }, function () {
            $(this).find("b").hide();
        })
    });
    //将数据添加到父页面对应的教师id及教师name

    function addParent(iId,sName) {
        var start_time = $("#date").val()+' '+$("#times").val().substr(0,5)+':00',
        end_time = $("#date").val()+' '+$("#times").val().substr(6,5)+':00';
        $.ajax({
            url: "<?php xcho($sSearchCheckAjax)?>",
            dataType: 'json',
            cache:false,
            data: {
                // our hypothetical feed requires UNIX timestamps
                start_time: start_time,
                end_time: end_time,
                teacher_id:iId,
            },
            success: function(aData) {
                if(aData.length > 0) {
                    var showHtml = '';
                    $.each(aData,function (key,val) {
                        showHtml = showHtml + '<tr class="warning"><td>'+val['cname']
                        +"</td><td>" + val['sname'] + '</td><td>' + val['lesson_time'] + '</td></tr>';
                    });
                    $("#show_data").html(showHtml);
                    $('#check-group').modal({
                        keyboard: false,
                        backdrop: false
                    });
                    $('#check-group').on('shown.bs.modal', function (e) {
                        // 关键代码，如没将modal设置为 block，则$modala_dialog.height() 为零
                        $(this).css('display', 'block');
                        $(this).find('.modal-dialog').css({
                            'margin-top': "100px"
                        });
                    });
                    $("#save").attr('data-id',iId);
                    $("#save").attr('data-name',sName);
                } else {
                    addToParent(iId,sName);
                }
            }
        });
    }
    $("#save").on('click',function () {
        addToParent($(this).attr('data-id'),$(this).attr('data-name'));
    })
    function addToParent(iId,sName) {
        var teacher_name = $(".search_input").attr("data-special"),
            teacher_id = $(".search_input").attr("data-specials");
        //console.log(teacher_name);
        // console.log(teacher_id);
        var parentId=parent.$("#teacher_id").val(iId);
        var parentName=parent.$("#teacher_name").val(sName);
        parent.$("input[name="+teacher_id+"]").val(iId);
        parent.$("input[name="+teacher_name+"]").val(sName);
        // window.parent.document.getElementById("teacher_id").value = iId;
        // window.parent.document.getElementById("teacher_name").value = sName;
        var index = parent.layer.getFrameIndex(window.name); //先得到当前iframe层的索引
        parent.layer.close(index); //再执行关闭
    }
    var iOldId = '';
    $("table>tbody>tr>td>a.seeKeb").click(function(){
        var iId = $(this).parents("tr").data("id");
        if(iId != iOldId){
            iOldId = iId;
            $('#calendar').fullCalendar('destroy');
        }
        //console.log(iId);
        $('#calendar').fullCalendar({
            header: {
                left: 'prev,next today',
                center: 'title',
                right: 'month,basicWeek,basicDay'
            },
            defaultDate: $("input[name='date_time']").val(),
            navLinks: true, // can click day/week names to navigate views
            editable: true,
            eventLimit: true, // allow "more" link when too many events
            events: function(start, end, timezone, callback) {
                var ajUrl = $("input[name='ajax_url']").val();
                $.ajax({
                    url: ajUrl,
                    dataType: 'json',
                    cache:false,
                    data: {
                        // our hypothetical feed requires UNIX timestamps
                        start_time: start.unix(),
                        end_time: end.unix(),
                        user_id:iId,
                        user_type:"teacher"
                    },
                    success: function(doc) {
                        //console.log(doc);
                        //console.log(doc.sTitleName);
                        $(".student-title>h2").html(doc.sTitleName);
                        var events = [];
                        $.each(doc.aCourseLessons,function(i,val){
                            // console.log(val.data_type);
                            if(val.data_type=="course"){
                                events.push({
                                    id:val.id,
                                    title: val.user_name+'\r\n'+val.times+'('+val.arrange_status+')'+'\r\n'+val.cname,
                                    allDay:true,
                                    start: val.start_time,// will be parsed
                                    end:val.end_time,
                                    url:val.course_url,
                                });
                            }else if(val.data_type == "schedule"){
                                events.push({
                                    title: val.topic+'\r\n'+val.times,
                                    allDay:true,
                                    start: val.start_time,// will be parsed
                                    end:val.end_time,
                                    url:val.syllabus_url,
                                });
                            }
                        });
                        callback(events);
                        //新打开页面
                        $(".fc-event-container>a.fc-day-grid-event").attr("target","_blank");
                        $(".fc-more").click(function(){
                            $(".fc-body.fc-widget-content>.fc-event-container>a.fc-day-grid-event").attr("target","_blank");
                        })

                    }
                });
            },
        });
    })


</script>
<?php include_once TPL_PATH . 'public/foot_script.phtml'; ?>
<button id="top" style="height: 50px;width: 50px;"></button></body>

</html>
